<template>
  <div class="result">
    <div :class="['icon', status]">
      <van-icon :name="icon" color="#ffffff" size="45" />
    </div>

    <div class="container">
      <div class="label">{{ `支付${text}` }}</div>
      <div class="sub-title">
        <slot name="sub-title" />
      </div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Icon } from 'vant'

Vue.use(Icon)

export default {
  props: {
    status: {
      type: String,
      required: true,
      validator: e => ['success', 'error'].includes(e)
    }
  },

  computed: {
    icon() {
      const { status } = this

      switch (status) {
        case 'success':
          return 'success'
        case 'error':
          return 'fail'
        default:
          return ''
      }
    },

    text() {
      const { status } = this

      switch (status) {
        case 'success':
          return '成功'
        case 'error':
          return '失败'
        default:
          return ''
      }
    }
  }
}
</script>

<style lang="less" scoped>
.result {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 35px 0;

  .icon {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .success {
    background: linear-gradient(to bottom, #45bdff, #2188ff);
  }

  .error {
    background: linear-gradient(to bottom, #ff8e45, #ff5f21);
  }

  .container {
    margin-left: 18.5px;

    .label {
      font-weight: 500;
      font-size: 21px;
      color: #333333;
      line-height: 29.5px;
    }

    .sub-title {
      font-size: 14px;
      line-height: 20px;
      color: #333333;
    }
  }
}
</style>